package com.shm.baidu;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/**
 * @author SHM
 */
public class Main1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        String[] s1 = s.split(" ");
        int n = Integer.parseInt(s1[0]);
        int m = Integer.parseInt(s1[1]);
        int p = Integer.parseInt(s1[2]);
        int[][] arr = new int[m][2];
        for (int i = 0; i < m; i++) {
            String str = in.nextLine();
            String[] s2 = str.split(" ");
            int u = Integer.parseInt(s2[0]);
            int v = Integer.parseInt(s2[1]);
            arr[i] = new int[]{u,v};
        }
        List<List<Integer>> lists = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            lists.add(new ArrayList<>());
        }
        for (int[] ints : arr) {
            lists.get(ints[0]).add(ints[1]);
        }
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < lists.size(); i++) {
            list.add(i);
            list.addAll(lists.get(i));
            System.out.println(list);
        }
    }
}